package com.dao;

import com.entity.Teachers;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import java.util.List;

public interface TeachersMapper {

    //从中间表中根据学生编号查询教师集合
    @Select("select * from teachers where tid in (select tid from students_teachers where sid=#{sid})")
    public List<Teachers> queryTeachersFromStudentsAndTeachersBySid(Integer sid);

    //根据教师编号查询带学生集合信息的教师信息
    @Select("select * from teachers where tid = #{tid}")
    @Results({
            @Result(id=true,property = "tid",column = "tid"),
            @Result(property = "stus",column = "tid",many=@Many(select = "com.dao.StudentsMapper.getStudentsFromStudentsAndTeachersByTid"))
    })
    public Teachers queryTeacherWithStudentsByTid(Integer tid);

}
